//	--------------------------------------------------------------------
//	Copyright(C) 2006,2007 Zhao Yukun. All rights reserved.
//	This file is a part of the Xeres system.
//	Xeres 2007
//	Contact : xeres.engine@gmail.com
//	$(reservedInfo)
//	$(reservedDeclaration)
//	--------------------------------------------------------------------
///	@file	<CTechnique9.h>
///	@path	~/src/graphics/dx9/
///	@date	2007/11/16
///	@desc	Technique implementation in DX9.

#pragma once

#include "xeres.h"

#include "graphics/IEffect.h"
#include "graphics/ITechnique.h"
#include "graphics/IShaderVariable.h"
#include "graphics/dx9/CDevice9.h"
#include "graphics/dx9/CEffect9.h"

namespace xeres {
	
	/*!
		\class	CTechnique9
		\brief
	*/
	class CTechnique9 : public ITechnique
	{
	public:

		/// \ctor
		CTechnique9( RefWeak<IEffect> effect , D3DXHANDLE technique );

		/// \dtor
		virtual ~CTechnique9( void );

		DECL_IOBJECT_CLASS( CTechnique9 , ITechnique );

	public:

	//@ interface

		/// \impl
		virtual size_t GetVariableCount( void );

		/// \impl
		virtual RefPass< IShaderVariable > GetVariableByIndex( size_t index );

		/// \impl
		virtual RefPass< IShaderVariable > GetVariableByName( const AString& name );

		/// \impl
		virtual RefPass< IShaderVariable > GetVariableBySemantic( const AString& semantic );

		/// \impl
		virtual const WString& GetName( void );

		/// \impl
		virtual size_t GetPassCount( void );

		/// \impl
		virtual RefWeak<IEffect> GetEffect( void );

		/// \impl
		virtual void Begin( uint pass , RenderContext& rc );

		/// \impl
		virtual void End( uint& pass , RenderContext& rc );

		/// \impl
		virtual void Draw( RenderContext& rc , RefWeak<IGeometry> geometry );

	private:

		//@ friend
		friend class CEffect9;

	//@ data

		// effect
		Ref<IEffect>			m_effect;

		// effect of interface
		ID3DXEffect *			m_pEffect;

		// technique interface
		D3DXHANDLE				m_pTechnique;

		// technique desc
		D3DXTECHNIQUE_DESC		m_desc;

		// technique name
		WString					m_name;
	};

} // namespace xeres
